package com.zxjbyte.yiyi.server.controller.demo;

import com.google.common.collect.Lists;
import com.zxjbyte.yiyi.framework.common.core.excel.DynamicColumnWidthStrategy;
import com.zxjbyte.yiyi.framework.common.core.excel.MultipleImageWriteStrategy;
import com.zxjbyte.yiyi.framework.common.domain.api.R;
import com.zxjbyte.yiyi.framework.common.util.EasyExcelUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author zhangxingjia
 * @Date 2025/10/24 22:30
 * @Version: 1.0
 */
@Slf4j
@Tag(name = "文件导入导出Demo")
@RestController
@RequestMapping(value = "/file_demo")
public class DemoFileController {


    @PostMapping("/export")
    public void export(HttpServletResponse response) {
        List<List<String>> hand = Lists.newArrayList();
        List<String> list = Lists.newArrayList();
        list.add("单行文本");
        List<String> list2 = Lists.newArrayList();
        list2.add("图片");
        hand.add(list);
        hand.add(list2);

        List<List<Object>> data = Lists.newArrayList();
        List<Object> data1 = Lists.newArrayList();
        data1.add("1111111111");
        data1.add("http://127.0.0.1:8081/yiyi/system/oss/get/file/20251024/1e00b0564eb84558af2a0eea12f5ae92.jpg,http://127.0.0.1:8081/yiyi/system/oss/get/file/20251024/73f8897359c749e6b3f271a2d40b3398.jpg,http://127.0.0.1:8081/yiyi/system/oss/get/file/20251024/208aee1603ee44369191b8c7d61d1a36.jpg,http://127.0.0.1:8081/yiyi/system/oss/get/file/20251024/47eb5089009c47d39a0d2607fced0e41.doc,http://127.0.0.1:8081/yiyi/system/oss/get/file/20251024/ee33a3a6afa84515b53a7c069bc2b6c6.jpg");
        data.add(data1);

        List<Integer> imageColumnIndexList = Lists.newArrayList();
        imageColumnIndexList.add(1);
        MultipleImageWriteStrategy multipleImageWriteStrategy = new MultipleImageWriteStrategy(imageColumnIndexList);
        DynamicColumnWidthStrategy dynamicColumnWidthStrategy = new DynamicColumnWidthStrategy();
        EasyExcelUtil.noModelWriteWeb(response, "111.xlsx", "11", hand, data, dynamicColumnWidthStrategy, multipleImageWriteStrategy);
    }
}
